package com.mapper;

import com.pojo.Admin;
import com.pojo.Notice;
import com.pojo.Teacher;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.sql.Timestamp;
import java.util.List;
import com.pojo.fileData;

@Mapper
public interface fileMapper {


    @Select("SELECT file_address FROM fileinf WHERE student_id = #{id}")
    String getfileAddress(Integer id);

    @Select("SELECT stunum FROM student WHERE teacher_id = (SELECT teacher_id FROM teacher where jobnum = #{id})")
    Integer getStudentId(Integer id);

    @Select("SELECT nickname FROM student WHERE teacher_id = (SELECT teacher_id FROM teacher where jobnum = #{id})")
    String getStudentName(Integer id);

    @Update("update fileinf set time = #{d}")
    void updateCurrentTime(Timestamp d);

    @Select("select * from fileinf order by releaseTime desc limit #{page},#{pagesize}")
    List<fileData> getAll(Integer page, Integer pagesize);

    @Select("select count(*) from fileinf")
    Integer countAll();

    @Select("select * from fileinf where sender = #{sender} and type = #{type} order by releaseTime desc limit #{page},#{pagesize}")
    List<fileData> getList(Integer sender,Integer type,Integer page,Integer pagesize);

    @Select("select count(*) from fileinf where sender = #{sender} and type = #{type}")
    Integer countList(Integer sender,Integer type);

}
